from flask import Flask
# from app.blog import views as blog  #放外面
from flask_migrate import Migrate
# from app.extensions import db
from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

migrate = Migrate()
def create_app():
    app = Flask(__name__)
    app.config.from_pyfile('setting.py')
    #注册SQLALchemy对象
    db.init_app(app)

    #初始化迁移对象
    migrate.init_app(app,db)
    #注册蓝图
    from app.blog import views as blog   #放里面，推荐
    app.register_blueprint(blog.bp)
    from app.blog import model
    from app.admin import models

    #注册url匹配规则
    app.add_url_rule(rule='/',endpoint='index',view_func=blog.index)



    return app